Skip to content

perf: replace seq_cst with acquire-release memory ordering - #10

Merged
HawkinWay merged 3 commits into
mainfrom
3-feature-optimize-memory-order
Jul 25, 2026
Merged

perf: replace seq_cst with acquire-release memory ordering#10
HawkinWay merged 3 commits into
mainfrom
3-feature-optimize-memory-order

Conversation

@HawkinWay

@HawkinWay HawkinWay commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Changes

  • Replace default std::memory_order_seq_cst operations with explicit memory ordering.
  • Use acquire/release synchronization between producer and consumer.
  • Keep local index reads as relaxed operations where synchronization is unnecessary.
  • Update benchmark implementation for more accurate throughput measurement.
  • Unified MSVC runtime library configuration to /MD
  • Enabled gtest_force_shared_crt for Windows builds

CMakeLists Motivation

Windows CI failed during linking because GoogleTest and project targets used different MSVC runtime libraries:

  • Project: /MD (Dynamic CRT)
  • GoogleTest: /MT (Static CRT)

This caused LNK2038 and multiple definition errors.

Observation

The performance improvement compared with seq_cst is limited.

This suggests that the current bottleneck is likely not memory ordering itself, but cache-line contention between write_idx and read_idx.

The next optimization will focus on cache-line alignment and false sharing elimination.

@HawkinWay
HawkinWay merged commit 05ad146 into main Jul 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant